package com.cdc.sboot.param;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/get")
public class Param1 {
	/**
	 * http://192.168.0.164:8084/get/after/123
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/after/{id}", method = RequestMethod.GET)
	public String after(@PathVariable("id") Integer id) {
		return "id: " + id;
	}

	
	/**
	 * http://192.168.0.164:8084/get/100/before
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "/{id}/before", method = RequestMethod.GET)
	public String before(@PathVariable("id") Integer id) {
		return "id: " + id;
	}

	
	/**
	 * http://192.168.0.164:8084/get/origin?id=90
	 * @param idP
	 * @return
	 */
	@RequestMapping(value = "/origin", method = RequestMethod.GET)
	public String origin(@RequestParam("id") Integer idP) {
		return "id: " + idP;
	}

	/**
	 * http://192.168.0.164:8084/get/origindefault?id=90 可以不传id,并且给id设置了默认值
	 * 
	 * @param idP
	 * @return
	 */
	@RequestMapping(value = "/origindefault", method = RequestMethod.GET)
	public String origindefault(@RequestParam(value = "id", required = false, defaultValue = "0") Integer idP) {
		return "id: " + idP;
	}
	
	/**
	 * http://192.168.0.164:8084/get/origindefaultsimple?id=90 可以不传id,并且给id设置了默认值
	 * 
	 * @param idP
	 * @return
	 */
	@GetMapping(value = "/origindefaultsimple")
	public String origindefaultsimple(@RequestParam(value = "id", required = false, defaultValue = "0") Integer idP) {
		return "id: " + idP;
	}

}
